﻿@model Nop.Admin.Models.WindAlert.SpotsGroupModel
@using Nop.Core.Domain.WindAlert;
@Html.ValidationSummary(false)
@Html.HiddenFor(model => model.Id)


<div id="spot-edit">
    <ul>
        <li @Html.RenderSelectedTabIndex(0, GetSelectedTabIndex())>
            @T("Admin.WindAlert.Spots.Info")
        </li>
        <li @Html.RenderSelectedTabIndex(1, GetSelectedTabIndex())>
            @T("Admin.WindAlert.Spots.Stations")
        </li>
    </ul>
    <div>
        @TabInfo()
    </div>
    <div>
        @TabSpots()
    </div>
</div>
<script>
    $(document).ready(function () {
        $("#spot-edit").kendoTabStrip({
            animation: {
                open: {
                    effects: "fadeIn"
                }
            },
            select: tabstrip_on_tab_select
        });
    });
</script>

@{
    //custom tabs
    var eventMessage = new AdminTabStripCreated(this.Html, "spot-edit");
    EngineContext.Current.Resolve<IEventPublisher>().Publish(eventMessage);
    foreach (var eventBlock in eventMessage.BlocksToRender)
    {
        @eventBlock
    }
}

    @*save selected tab index*@
	<input type="hidden" id="selected-tab-index" name="selected-tab-index" value="@(GetSelectedTabIndex())">

@helper TabInfo()
    { 
        <table class="adminContent">
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.Name):
            </td>
            <td class="adminData">
                @Html.EditorFor(x => x.Name)
                @Html.ValidationMessageFor(model => model.Name)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.Published):
            </td>
            <td class="adminData">
                @Html.EditorFor(x => x.Published)
                @Html.ValidationMessageFor(model => model.Published)
            </td>
        </tr>
        <tr>
            <td class="adminTitle">
                @Html.NopLabelFor(model => model.DisplayOrder):
            </td>
            <td class="adminData">
                @Html.EditorFor(model => model.DisplayOrder)
                @Html.ValidationMessageFor(model => model.DisplayOrder)
            </td>
        </tr> 
            <tr>
                <td class="adminTitle">
                    @Html.NopLabelFor(model => model.AlertOptionName):
                </td>
                <td class="adminData">
                    @Html.DropDownListFor(model => model.AlertOptionId, ((AlertOption)Model.AlertOptionId).ToSelectList())
                    @Html.ValidationMessageFor(model => model.AlertOptionId)
                </td>
            </tr>
    </table>
}

@helper TabSpots()
{
    if (Model.AvailableSpots != null && Model.AvailableSpots.Count > 0)
    {
        foreach (var spot in Model.AvailableSpots)
        {
            <input type="checkbox" name="SelectedSpotsIds" value="@spot.Id"
                   @if (Model.SelectedSpotsIds != null && Model.SelectedSpotsIds.Contains(spot.Id)) { <text> checked="checked" </text>   } />@spot.Name
                <br />
        }
    }
    else
    {
        @T("Admin.Windalert.spots.Fields.CameraNoRoles")
    }
}
